<template>
  <div>
    <div v-if="Show == 0">
      <div class="mlt">
        <el-button
          v-permissions="{ permission: ['add:ReportList'] }"
          type="primary"
          @click="addReport()"
        >
          新增报告
        </el-button>
      </div>
      <div class="mlt">
        <el-form class="demo-form-inline" :inline="true" :model="formInline">
          <el-form-item label="报告名称">
            <el-input v-model="formInline.report_name" placeholder="报告名称" />
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="init">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column label="报告名称" prop="report_name" />
        <el-table-column label="操作" prop="">
          <template slot-scope="scope">
            <el-button
              v-permissions="{ permission: ['edit:ReportList'] }"
              type="primary"
              @click="see(scope.row)"
            >
              查看
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div v-if="Show == 1">
      <AddReport :obj="obj" @showMain="showMain" />
    </div>
  </div>
</template>

<script>
  import { reportList } from '@/api/template'

  import AddReport from './components/addReport.vue'
  export default {
    components: {
      AddReport,
    },
    props: {},
    data() {
      return {
        formInline: {
          report_name: '',
          pagesize: 10,
          page: 1,
        },
        Show: 0,
        tableData: [],
        obj: {},
      }
    },
    mounted() {
      console.log(this.$route)
      if (this.$route.params.type == 'report') {
        this.Show = 1
      } else {
        this.init()
      }
    },
    beforeMount() {},
    methods: {
      init() {
        reportList(this.formInline).then((e) => {
          this.tableData = e.data.data
        })
      },
      onSubmit() {},
      see(e) {
        this.obj.id = e.id
        this.Show = 1
      },
      addReport() {
        this.Show = 1
        this.obj.id = null
      },
      handleClose(done) {
        this.$confirm('确认关闭？')
          .then(() => {
            done()
          })
          .catch(() => {})
      },
      showMain() {
        this.init()
        this.Show = 0
      },
      //
    },
  }
</script>

<style lang="scss" scoped>
  .sort-move {
    transition: transform 1s;
  }
</style>
